﻿using System.Linq;

using Styx;
using Styx.CommonBot;

using WuzzCollection.Helpers;

namespace WuzzCollection.Classes
{
    internal partial class Warrior : AbstractClass
    {
        public void ArmsRotation()
        {
            if (!Me.HasAura("Battle Stance"))
                if (Spell.CastSpecial("Battle Stance"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpecial("Recklessness"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpecial("Avatar"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpecial("Bloodbath"))
                    return;

            if (!Me.HasAura("Enrage") && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpecial("Berserker Rage"))
                    return;

            if (Me.CurrentRage >= 40 && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpecial("Deadly Calm"))
                    return;

            // Get some health is possible.
            if (Me.HasAura("Victorious") && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpecial("Impending Victory"))
                    return;
                else if (Spell.CastSpecial("Victory Rush"))
                    return;
            
            // Dayum Son...
            if ((Me.HasAura("Taste For Blood") && Me.Auras["Taste for Blood"].TimeLeft.Seconds <= 2)
                || (Me.HasAura("Taste For Blood") && Me.Auras["Taste for Blood"].StackCount == 5 && Me.HasAura("Overpower"))
                || (Me.HasAura("Taste For Blood") && Me.CurrentTarget.HasAura("Colossus Smash") && Me.CurrentTarget.Auras["Colossus Smash"].TimeLeft.Seconds <= 2 && SpellManager.Spells["Colossus Smash"].Cooldown)
                || (Me.HasAura("Deadly Calm") || Me.CurrentRage > 90)
                && Me.CurrentTarget.HealthPercent >= 20 && Me.CurrentTarget.HasAura("Colossus Smash") && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Heroic Strike"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Mortal Strike"))
                    return;

            if (!Me.CurrentTarget.HasMyAura("Colossus Smash") || Me.CurrentTarget.Auras["Colossus Smash"].TimeLeft.Milliseconds <= 1500 && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Colossus Smash"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Execute"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Storm Bolt"))
                    return;

            if (Me.HasAura("Overpower!") && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Overpower"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Shockwave"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Dragon Roar"))
                    return;

            if ((Me.CurrentRage >= 70 | Me.HasMyAura("Colossus Smash")) & Me.CurrentTarget.HealthPercent >= 20 && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Slam"))
                    return;

            if (Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Heroic Throw"))
                    return;

            if (Me.CurrentRage < 70 & !Me.CurrentTarget.HasMyAura("Colossus Smash"))
                if (Spell.CastSpecial("Battle Shout"))
                    return;

            if (SpellManager.Spells.ContainsKey("Colossus Smash") && SpellManager.Spells["Colossus Smash"].CooldownTimeLeft.Seconds >= 5 && !Me.CurrentTarget.HasMyAura("Colossus Smash") && Me.CurrentTarget.HealthPercent >= 20 && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Bladestorm"))
                    return;

            if (Me.CurrentTarget.HealthPercent >= 20 && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Slam"))
                    return;

            if (Me.CurrentTarget.HealthPercent >= 20 && Me.CurrentTarget.IsWithinMeleeRange)
                if (Spell.CastSpell("Impending Victory"))
                    return;

            if (Me.CurrentRage < 70)
                if (Spell.CastSpecial("Battle Shout"))
                    return;

            // Rage dump if absolutely nothing else to do. Needed for lower levels
            if (Me.CurrentRage > 80)
                if (Spell.CastSpell("Heroic Strike"))
                    return;
        }

    }
}